var express = require("express")
var router = express.Router()

const {  serveModel, signModel, doctor_teamModel, serve_packModel, serve_projectModel,organModel } = require("../db/people_model")


/* 待处理签约 */
router.get("/sign", async (req, res) => {
    let data = await signModel.find().populate("team").populate("serve")
    res.send({
        data,
        mes:"查找成功"
    })
})

// 查看服务包
router.get("/servelist", async (req, res) => {
    let data = await serve_packModel.find()
    res.send({
        data,
        mes:"查找成功"
    })
})

// 查看团队
router.get("/docteamlist", async (req, res) => {
    let data = await doctor_teamModel.find()
    res.send({
        data,
        mes:"查找成功"
    })
})

// 新增签约
router.post('/addSign', async (req, res) => {
    let body = req.body
    // console.log(body, 777);
    await signModel.create(body)
    res.send({
      'code': 200,
    })
  
  })

/* 待处理服务 */
router.get("/serve", async (req, res) => {
    let data = await serveModel.find().populate("team").populate("serve").populate("project")
    res.send({
        data,
        mes:"查找成功"
    })
})

/* 团队管理查询 */
router.get("/doctor_team", async (req, res) => {
    let data = await doctor_teamModel.find().populate("organ")
    res.send({
        data,
        mes:"查找成功"
    })
})



module.exports = router;